首先完成vrep的模擬設定
再來對著要新增程式的物件點選右鍵→add→Associated child script→threaded
會多出如下圖的圖示

點開上圖紅框內左邊的圖示並輸入以下程式碼
threadFunction=function()
sim.setThreadSwitchTiming(2) -- Default timing for automatic thread switching
-- Here we execute the regular thread code:
res,err=xpcall(threadFunction,function(err) return debug.traceback(err) end)
    if not res then
	sim.addStatusbarMessage('Lua runtime error: '..err)
    end
-- Put some clean-up code here:
simRemoteApi.start(19997)
end
到V-REP資料夾→programming→remoteApiBindings→python→python中
複製vrep.py和vrepConst.py
跟programming→remoteApiBindings→lib→lib→Windows→64Bit中
複製remoteApi.dll到你要存程式的資料夾中
打開wscite並輸入以下程式碼
import vrep
import sys, math
# child threaded script: 
# 內建使用 port 19997 若要加入其他 port, 在  serve 端程式納入
#simExtRemoteApiStart(19999)
 
vrep.simxFinish(-1)
 
clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
if clientID!= -1:
    print("Connected to remote server")
else:
    print('Connection not successful')
    sys.exit('Could not connect')
存成→檔名.py
並執行
如果執行結果為
Connected to remote server
>Exit code: 0
那就可以開始編寫程式了